package com.jerry.Future;

public class FutureTask<T> implements Future<T> {

    private boolean done = false;

    private final Object lockObject = new Object();

    private T result;
    @Override
    public boolean done() {
        return false;
    }

    @Override
    public T get() throws InterruptedException {
        synchronized (lockObject){
         while(!done){
             lockObject.wait();
         }
         lockObject.notifyAll();
         return  result;
        }
    }

    public void finishTask(T out){

        synchronized (lockObject){

         this.result = out;
         this.done = true;
         lockObject.notifyAll();

        }


    }
}
